Camera Control (iOS 18+) PRO
iOS 18 introduced the Camera Control — the dedicated hardware button on iPhone 16 (and on-screen control surface on other devices) that lets people adjust capture settings without diving into your UI. AVFoundation models this as a list of AVCaptureControl instances attached to the running AVCaptureSession. Scripting bridges all of them.
Detecting support
The hardware Camera Control only ships on iPhone 16 and later. Always feature-detect:
session.supportsControls is safe to call on older devices — Scripting wraps it with a respondsToSelector check so it just returns false rather than crashing.
Built-in system controls
The two most common controls are provided by the system; pass the device they should bind to:
The system writes the zoom factor / exposure bias straight back to the device for you. The action callback is purely informational — use it to update your own UI.
Custom slider
Continuous, stepped, or discrete-values:
Pass any SF Symbols name; Scripting does not validate it. If the symbol cannot be resolved at runtime the control simply renders without an icon.
Custom index picker
Use this when titles are non-numeric or non-uniform:
Adding controls to the session
addControl(...) follows the same rules as inputs/outputs: prefer configure(...) so the changes commit atomically. Adding more than maxControlsCount is a no-op (canAddControl returns false).
Receiving lifecycle events
AVCaptureSessionControlsDelegate tells you when the system Camera Control UI shows / hides — useful for dimming your own overlay while the system control is on screen.
Pass null to remove the delegate.
Hooking the hardware button to capture
The hardware Camera Control button does not dispatch through your control delegate by default — you must attach an AVCaptureEventInteraction. Without it, half-presses and full-presses are silently swallowed:
phase is "began" | "ended" | "cancelled". kind is "primary" for the main press and "secondary" for half-press / focus events.
Common pitfalls
- Delegate never fires. You forgot
setControlsDelegate(...), or the session never started running. - Hardware press does nothing. You forgot
new AVCaptureEventInteraction(...).attach(). supportsControlsisfalse. Either you are on a device without the hardware Camera Control, or the session has not been configured yet — always check afteraddInput(...).- Custom slider does not show. Either the SF Symbol name is wrong, or
maxControlsCountis exceeded — Scripting silently drops theaddControlcall in both cases.
